const { $http, target, $wx } = getApp()
Page({
    data: {
        count:5
    },
    onLoad(){
        const { id } = $wx.getUser()
        $http.pull(this,'ad', { param:{ many:0, location:'02', target } })
        $wx.login({ first: true })
        // if( id ){
        //     return this.login()
        // }
        let count = this.data.count
        clearInterval(this.clear)
        this.clear = setInterval(()=>{
            count --
            this.setData({ count })
            if(count === 1){
                clearInterval(this.clear)
                this.login()
            }
        }, 1000)
    },
    login(){
        wx.switchTab({ url: '/pages/tabs/home/index' })
    },
    onSkip(){
        this.login()
        clearInterval(this.clear)
    }
})